package com.wo.cloud.admin.feign;

import com.wo.cloud.admin.entity.SysLog;
import com.wo.cloud.admin.service.ISysLogService;
import com.wo.cloud.core.entity.Response;
import com.wo.cloud.log.feign.ISysLogFeign;
import com.wo.cloud.core.entity.CommonLog;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2021/4/30 15:24
 * Description:
 */

@Service
@Slf4j
@RestController
@AllArgsConstructor
@Api(tags = "日志远程调用")
public class SysLogProvider implements ISysLogFeign {

    @Autowired
    private ISysLogService sysLogService;

    @Override
    @PostMapping("/sys/log/set")
    public Response<Boolean> set(CommonLog commonLog) {
        SysLog sysLog = new SysLog();
        BeanUtils.copyProperties(commonLog, sysLog);
        return Response.data(sysLogService.save(sysLog));
    }
}
